<?php

namespace App\Http\Validate\Order;

use App\Http\Validate\BaseValidate;

/**
 * 销售订单预开发票验证器
 */
class Saleorderinvoice extends BaseValidate
{
    //验证规则
    protected $rule = [];
    //自定义验证信息
    protected $message = [];

    public function __construct($doaction = 'add')
    {
        if ($doaction == 'add') {
            $this->rule = [
                'id' => 'required',
                'type' => 'required',
                // 'category' => 'required',
                'company_code' => 'required',
                'order_number' => 'required',
                'document_number' => 'required',
                'document_date' => 'required',
                'firm_name' => 'required',
                'credit_code' => 'required',
                'firm_address' => 'required',
                'firm_phone_number' => 'required',
                'firm_bank' => 'required',
                'firm_bank_number' => 'required',
                'firm_email' => 'required',
                // 'business_license' => 'required',
                // 'account_opening_permit' => 'required',
                // 'attorney' => 'required',
            ];
            $this->message = [
                'id.required' => 'id不能为空',
                'type.required' => '类型不能为空',
                // 'category.required' => '往来单位性质不能为空',
                'company_code.required' => '往来单位编码不能为空',
                'order_number.required' => '销售订单号不能为空',
                'document_number.required' => '单据编号不能为空',
                'document_date.required' => '单据日期不能为空',
                'firm_name.required' => '公司名称不能为空',
                'credit_code.required' => '统一信用代码不能为空',
                'firm_address.required' => '公司地址不能为空',
                'firm_phone_number.required' => '公司电话不能为空',
                'firm_bank.required' => '公司开户行不能为空',
                'firm_bank_number.required' => '公司账户不能为空',
                'firm_email.required' => '公司邮箱不能为空',
                // 'business_license.required' => '上传营业执照不能为空',
                // 'account_opening_permit.required' => '上传开户许可证不能为空',
                // 'attorney.required' => '上传委托书不能为空',
            ];
        } elseif($doaction == 'invoice') {
            $this->rule = [
                'id' => 'required',
                'status' => 'required|in:1,2,3,4',
            ];
            $this->message = [
                'id.required' => 'id不能为空',
                'status.required' => '审核状态不能为空',
                'status.in' => '无效参数',
            ];
        }
    }
}
